import Vue from 'vue'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App.vue'
import router from './router'
import {postRequest,putRequest,postKeyValueRequest,getRequest,deleteRequest} from "@/util/api";
import store from "./store";
import {initMenu} from "@/util/menu";
import "font-awesome/css/font-awesome.min.css"
import echarts from 'echarts'
Vue.prototype.$echarts = echarts

Vue.config.productionTip = false
//把这些请求组件 放到prototype 中去
Vue.prototype.postRequest = postRequest;
Vue.prototype.putRequest = putRequest;
Vue.prototype.postKeyValueRequest = postKeyValueRequest;
Vue.prototype.getRequest = getRequest;
Vue.prototype.deleteRequest = deleteRequest;

Vue.use(ElementUI);

//全局的路由守卫
router.beforeEach(((to, from,next) => {
  if(to.path == "/"){
    next();
  } else {
    //如果访问的不是根路径，初始化所有的菜单页面
    initMenu(router,store)
    next();
  }
}))

new Vue({
  router,//使用路由
  store,//使用Vuex
  render: h => h(App),
}).$mount('#app')
